<!DOCTYPE html>
<html>

<include file="./Application/Admin/View/common/css-js.html"/>
<link rel="stylesheet" type="text/css" href="/Public/layui/css/layui.css" />
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>商品列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <div  class="col-sm-2" style="width: 160px">
                        <div class="input-group" >
                            <button class="btn btn-default btn-sm" type="button" data-toggle="refresh" style="margin-right: 10px;"><a href="/index.php/Admin/Order/index"><i class="fa fa-refresh"></i></a></button>
                        </div>
                    </div>
                    <form name="admin_list_sea" class="form-search" method="post" action="/index.php/Admin/Order/index">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" id="key" class="form-control" name="keywords" value="{:I('keywords', '')}" placeholder="输入订单编号/购买人手机号" />
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                        <tr class="long-tr">
                            <th data-toggle="true">订单id</th>
                            <th>订单编号</th>
                            <th>商品名称</th>
                            <th>商品货号</th>
                            <th>购买人</th>
                            <th>价格</th>
                            <th>购买时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="list-content">
                        <volist name="list" id="vo">
                            <tr>
                                <td>{$vo.id}</td>
                                <td>{$vo.order_sn}</td>
                                <td>{$vo.goods_name}</td>
                                <td>{$vo.goods_sn}</td>
                                <td>{$vo.tel}</td>
                                <td>￥{$vo.real_pay_amount|fen_to_yuan}</td>
                                <td>{$vo.add_time|time_format}</td>
                                <td>
                                    <if condition="$vo.send_goods eq 1">
                                        <span style="color: #18a689;">已发货</span>
                                        <else />
                                        <button type="button" class="btn btn-success send-goods" data-url = "/index.php/Admin/Order/sendGoods/id/{$vo.id}/type/1">发货</button>
                                    </if>
                                </td>
                            </tr>
                        </volist >
                        </tbody>
                    </table>
                    <div id="page" style=" text-align: right;"></div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<script src="/Public/layui/layui.js"></script>
<script>
    layui.use(['laypage', 'layer'], function(){
        laypage = layui.laypage;
        layer = layui.layer;
        laypage.render({
            elem: 'page', //注意，这里的 test1 是 ID，不用加 # 号
            count: '{$count}', //数据总数，从服务端得到
            limit:15,
            curr: '{$p}',
            jump: function(obj, first){
                //首次不执行
                if(!first){
                    location.href = '/index.php/Admin/Order/index/p/' + obj.curr;
                }
            }
        });

        $('.send-goods').click(function () {
            var url = $(this).data('url');
            var index = layer.load();
            var self = $(this);
            getData({}, url, function (res) {
                if (res.status == 1) {
                    console.log($(this).parent());
                    self.parent().html('<span style="color: #18a689;">已发货</span>');
                    layer.msg(res.info, {icon: 1});
                } else {
                    layer.msg(res.info, {icon: 2});
                }

                layer.close(index);
            });
        });

        function getData(data,url,success) {
            $.ajax({
                type: "GET",
                url: url,
                dataType: 'json',
                timeout: 10000,
                data:data ,
                success: success,
                error: function () {
                    alert('程序出错');
                }
            });
        }
    })

</script>

</body>

</html>
